home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!xanthas
- From: xanthas@netcom.com (Mike Day)
- Subject: Watcom C/C++ Gurus: Please Help.
- Message-ID: <xanthasDL2rIv.H8x@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- Date: Fri, 12 Jan 1996 15:40:05 GMT
- Sender: xanthas@netcom19.netcom.com
-
-
- Thanks for reading.
-
- For reference: I am using Watcom C/C++ version 10.0, in DOS, in
- protected mode via DOS4GW. I have years of experience in both C/C++ and
- Assembly. I have experience with hooking and handling interrupts but not
- in protected mode.
-
-
- I am trying to write a program that acts like a TSR. It hooks some
- interrupts to enable a hot key to popup a subprogram, then uses spawnl() to
- run command.com. When command.com exits, it unhooks the interrupts. So,
- its like a fake popup TSR.
-
- Within this fake popup TSR I must hook the following interrupts:
-
- Description: Vector:
-
- Timer 0x08
- Keyboard 0x09
- Video 0x10
- Disk 0x13
- Idle 0x28
- CtrlC 0x1B
- CtrlBreak 0x23
- CritError 0x24
-
- My hook functions are declared like this:
-
- void __interrupt __far Timer();
- etc..etc..
-
- After compiling a test program and viewing its assembly language in the
- debugger, I discovered the following...
-
- At the beginning of each of my hook functions, Watcom produces this code:
-
- pushad
- push ds
- push es
- push fs
- push gs
- mov ebp,esp
- sub esp,00000000 ; number of bytes needed for local vars
- cld
- call __GETDS
-
- At the end of each of my hook functions, Watcom produces the following code:
-
- mov esp,ebp
- pop gs
- pop fs
- pop es
- pop ds
- popad
- iretd
-
- This causes problems when I hook the Disk and Video interrupts. The
- normal implementation of those interrupts causes certain registers and
- flags to be changed upon exit. With Watcom's above code, I cannot hook
- those interrupts properly.
-
- In real mode, in a previous (and similar) project, my Disk function was
- looked like this in assembly:
-
- Disk PROC
- ; Indicate we're inside disk interrupt
- mov cs:disk.active,1
-
- ; Fake call to old interrupt
- pushf
- call disk.old
-
- ; Indicate we're outside disk interrupt
- mov cs:disk.active,0
-
- ; Fake IRET without changing flags
- sti
- ret 2
- Disk ENDP
-
- (BTW, the above code worked perfectly. The reason I did this is to have
- a way to prevent the hotkey from activating my popup program during disk
- activity.)
-
- Now I need to do the equivalent in Watcom C/C++, in protected mode.
-
- How do I do this? Any ideas? Have you done anything similar?
-
- I've tried to get around the problem a couple ways... First, I tried
- using auxilary pragmas to negate Watcom's code. The only problem then
- is, I lose the data segment, and I can't get it back using "call
- __GETDS", because the compiler says its undefined. Second, I tried
- writing external assembly procedures rather than C ones, but I still had
- the data segment problem (DGROUP was undefined).
-
- Thanks for reading and any/all help.
- --
- Mike Day
- please post answers and/or email them to:
- xanthas@netcom.com
- or
- omni@pe.net
-
-
-